unit uAppSetIniFile;

interface

uses
  Classes, SysUtils, uClasses, uAppSet, IniFiles, uAppUtils;

type

  TAppSetIniFile = class(TLifeInterface, IAppSet)
  private
  protected
    FIniFile : TIniFile;

    function GetIsFirstRun : boolean;
    procedure SetIsFirstRun(Value : boolean);
  public
    constructor Create;
    destructor Destroy; override;

    function Instance : TObject;

    property IsFirstRun : boolean read GetIsFirstRun write SetIsFirstRun;
  end;

implementation

{ TAppSetIniFile }

constructor TAppSetIniFile.Create;
begin
  FIniFile := TIniFile.Create(TAppUtils.AppPath + 'AppSet.ini');
end;

destructor TAppSetIniFile.Destroy;
begin
  FIniFile.UpdateFile;
  FIniFile.Free;

  inherited;
end;

function TAppSetIniFile.GetIsFirstRun: boolean;
begin
  result := FIniFile.ReadBool('GlobalSetting', 'FristRun', true);
end;

function TAppSetIniFile.Instance: TObject;
begin
  result := self;
end;

procedure TAppSetIniFile.SetIsFirstRun(Value: boolean);
begin
  FIniFile.WriteBool('GlobalSetting', 'FirstRun', Value);
end;

initialization
  AppSet := TAppSetIniFile.Create;

finalization
  if Assigned(AppSet) then
  begin
    AppSet := nil;
  end;

end.
